<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
	<head th:include="common/headers::tree(#{systemName})"></head>
	<script type="text/javascript">
	$(function(){
		$('#tree').systemTree({
			loadUrl: parent.CONTEXT_PATH+"/system/menu/loadChildrenNodes",
			insertUrl: parent.CONTEXT_PATH+"/system/menu/insert",
			editUrl: parent.CONTEXT_PATH+"/system/menu/loadOne/",
			updateUrl: parent.CONTEXT_PATH+"/system/menu/update",
			removeUrl: parent.CONTEXT_PATH+"/system/menu/delete/",
			dragAnddropUrl: parent.CONTEXT_PATH+"/system/menu/saveDragAndDrop",
			initAddValue: {isuse: true, iconAddress: "icon-chevron-right"},
			validateFieldsJson: {
				cdNm:{
					validators: {
						notEmpty: { message: '菜单名称不能为空'},
						stringLength: { min: 1, max: 30, message: '菜单名称长度必须在1到30之间'},
					}
				},
				orderCd:{
					validators: {
	                    regexp: {
	                        regexp: /^[1-9][0-9]{0,7}$/,
	                        message: '请输入不超过8位长度的正整数'
	                    }
                    }
				},
				iconAddress:{
					validators: {
						notEmpty: { message: '图标地址不能为空'},
						stringLength: { min: 1, max: 50, message: '图标地址长度必须在1到50之间'}
					}
				},
				linkAddress:{
					validators: {
						notEmpty: { message: '链接地址不能为空'},
						stringLength: { min: 1, max: 100, message: '链接地址长度必须在1到100之间'}
					}
				},
				menuMarker:{
					validators: {
						notEmpty: { message: '菜单标识不能为空'},
						stringLength: { min: 1, max: 30, message: '菜单标识长度必须在1到30之间'},
						remote: {url: parent.CONTEXT_PATH+"/system/menu/validate", message: '菜单标识已存在', delay: 600, type: "GET",
	                        	data: function(validator) {
	                                return { idKey: $("#idKey").val()};
	                            }
                        }
					}
				}			
			},
			specialItemsJson: [
				{itemId: "isuse", itemType: "radio"},
				{itemId: "resourceId", itemType: "singleSelector"}
			]
		});
	});
	</script>
	<body>
		<div class="content_wrap">
			<div class="left">
				<ul id="tree" class="ztree"></ul>
			</div>
			<div class="right">
				<div th:include="common/toolbarTop::tree('system:SysMenu:delete','system:SysMenu:insert')"></div>
				<div class="body" style="display: none;">
					<form id="inputForm" class="form-horizontal" role="form">
						<!-- form内input对象的type属性不能为hidden，否则修改时无法赋值 -->
						<input id="idKey" name="idKey" type="text" class="hidden">
						<input id="parentId" name="parentId" type="text" class="hidden">
						<div class="form-group">
							<label for="cdNm" class="col-sm-2 control-label">菜单名称</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="cdNm" id="cdNm">
							</div>
						</div>
						<div class="form-group">
							<label for="orderCd" class="col-sm-2 control-label">排序码</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="orderCd" id="orderCd">
							</div>
						</div>
						<div class="form-group">
							<label for="iconAddress" class="col-sm-2 control-label">菜单图标</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="iconAddress" id="iconAddress">
							</div>
						</div>
						<div class="form-group">
							<label for="linkAddress" class="col-sm-2 control-label">链接地址</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="linkAddress" id="linkAddress">
							</div>
						</div>
						<div class="form-group">
							<label for="menuMarker" class="col-sm-2 control-label">菜单标识</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="menuMarker" id="menuMarker">
							</div>
						</div>
						<div class="form-group">
							<label for="resourceId" class="col-sm-2 control-label">资源id</label>
							<div class="col-sm-10">
								<span th:include="common/selector::formSelector0('resourceId',
										  '/loadResourceTreeExceptButton','idKey','textValue','','','','','','','','','')"></span>
							</div>
						</div>
						<div class="form-group">
							<label for="isuse" class="col-sm-2 control-label">是否启用</label>
							<div class="col-sm-10">
								<div class="btn-group" data-toggle="buttons">
									<label class="btn btn-default">
										<input type="radio" name="isuse" value="true"> 是 
									</label>
									<label class="btn btn-default">
										<input type="radio" name="isuse" value="false"> 否 
									</label>
								</div>
							</div>
						</div>
						<div class="form-group">
							<label for="treeLevel" class="col-sm-2 control-label">节点级数</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="treeLevel" id="treeLevel" readonly>
							</div>
						</div>
						<div class="form-group">
							<label for="remarks" class="col-sm-2 control-label">备注</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="remarks" id="remarks">
							</div>
						</div>
					</form>
					<div style="text-align: center;">
						<div th:include="common/toolbarBottom::tree('system:SysMenu:insert','system:SysMenu:update')"></div>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>